﻿namespace CodingExercises._21_30;

public class CalculaterFactorial
{
    // 使用递归计算阶乘
    public static int Method(int number)
    {
        if (number < 0)
        {
            throw new ArgumentException("Factorial is not defined for negative number.", nameof(number));
        }

        if (number == 0 || number == 1)
            return 1;
        return number * Method(number - 1);
    }
}